<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<script th:inline="javascript">
var cityId = '[(${cityId})]';
var countryId = '[(${countryId})]';
var isCity = [(${isCity})];
var isCountry = [(${isCountry})];

function doGetCityCountry[(${rid})](data) {
	var arrCity = data.city;
	var arrCountry = data.country;
	if (isCity) {
		if (findObj('[(${cityId})]') == null) myMsg('缺少城市输入框', 'warn');
		else {
			let opts = '';
			for (var k in arrCity) {
				var json = arrCity[k];
				opts += '<option value="' + json.id + '">' + json.name + '</option>';
			}
			$(findObj('[(${cityId})]')).html(opts);
		}
	}
	if (isCountry) {
		if (findObj('[(${countryId})]')==null) myMsg('缺少区县输入框', 'warn');
		else {
			let opts = '';
			for (var k in arrCountry) {
				var json = arrCountry[k];
				opts += '<option value="' + json.id + '">' + json.name + '</option>';
			}
			$(findObj('[(${countryId})]')).html(opts);
		}
	}
}

function ajaxShowCityCountry[(${rid})](province, city) {
	var ajaxData = {
		"rid": "[(${rid})]",
		"cityId": "[(${cityId})]",
		"countryId": "[(${countryId})]",
		"isCity":  [(${isCity})],
		"isCountry":  [(${isCountry})],
		"province":  province,
		"city": city,
	}

	ajaxPost('/flow/macro/getCityCountry', ajaxData).then((res) => {
		console.log('res', res);
		doGetCityCountry[(${rid})](res.data);
	});
}
</script>
</body>
</html>